
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<title>Resource Selection </title>
	<STYLE>.toolbartable
{
	background: #889CD5;
	font-size: 15px;
	font-family: Verdana,Tahoma;
	color: Black;
}
.toolbartext
{
	font-size: 12px;
	font-family: Verdana,Tahoma;
	font-weight:bolder;
	color: Black;
}
.toolbarselect
{
	font-size: 11px;
	font-family: Verdana,Tahoma;
	font-weight:normal;
}
.toolbarbutton
{
    FONT-SIZE: 11px;
    FONT-FAMILY: Verdana,Tahoma;
    BACKGROUND-COLOR: #cccccc;
    color:Black;
    border-color:Silver;
}
.toolbartitleheading
{
	font-size: 15px;
	font-family: Verdana,Tahoma;
	color: Black;
	text-align:right;
}
.toolbartitle
{
	font-size: 15px;
	font-family: Verdana,Tahoma;
	color: Black;
	text-align:right;
	font-weight:bolder;
}


.toolboxtable
{
	background:  #889CD5;
	font-size: 15px;
	font-family: Verdana,Tahoma;
	color: Black;
}
.toolboxinternaltable
{
	background:  #889CD5;
	font-size: 15px;
	font-family: Verdana,Tahoma;
	color: Black;
}
.toolboxheading
{
	background: black;
	font-size: 12px;
	font-family: Verdana, Tahoma;
	color: White;
	font-weight:bolder;
	text-align:center;
}
.toolboxcolumn
{
    FONT-SIZE: 11px;
    FONT-FAMILY: Verdana,Tahoma;
    BACKGROUND-COLOR:  #889CD5;
    color:white;
    border-color:White;
    border-top: 1px ridge #C6B36C;
	border-right: 1px ridge #413400;
	border-bottom: 1px ridge #413400;
	border-left: 1px ridge #C6B36C;
}
.toolboxbuttons
{
    FONT-SIZE: 11px;
    FONT-FAMILY: Verdana,Tahoma;
    BACKGROUND-COLOR: #889CD5;
    color:white;
    border-color:White;
}
.toolboxparent
{
	background:  #C4D2FB;
	font-size: 11px;
	font-family: Verdana, Tahoma;
	color: black;
	font-weight:bolder;
	text-align:center;
}
.toolboxparentbevell
{
	background:  #889CD5;
	font-size: 11px;
	font-family: Verdana, Tahoma;
	color: White;
	font-weight:bolder;
	text-align:center;
	border-top: 1px ridge #C6B36C;
	border-right: 1px ridge #413400;
	border-bottom: 1px ridge #413400;
	border-left: 1px ridge #C6B36C;
}


.imagetable
{
	background: #C4D2FB;
}
.imageiframe
{
	background: #FFFF66;
}



.propertiesboxtable
{
	background: #889CD5;
	font-size: 15px;
	font-family: Verdana,Tahoma;
	color: Black;
}
.propertiesboxheading
{
	background: Black;
	font-size: 12px;
	font-family: Verdana, Tahoma;
	color: White;
	font-weight:bolder;
	text-align:center;
}
.propertiesboxactionselect
{
	font-size: 11px;
	font-family: Verdana,Tahoma;
	font-weight:normal;
}
.propertiesboxbuttons
{
    FONT-SIZE: 11px;
    FONT-FAMILY: Verdana,Tahoma;
    BACKGROUND-COLOR: #cccccc;
    color:black;
    border-color:silver;
}
.propertiesboxpropertytable
{
	background: Silver;
	font-size: 15px;
	font-family: Verdana,Tahoma;
	color: Black;
}
.propertiesboxpropertyextraspace
{
	background:  #C4D2FB;
	font-size: 15px;
	font-family: Verdana,Tahoma;
	color: Black;
}
.propertiesboxpropertybuttonstable
{
	background:  #C4D2FB;
	font-size: 15px;
	font-family: Verdana,Tahoma;
	color: Black;
}
.propertiesboxinput
{
	FONT-SIZE: 11px;
    FONT-FAMILY: Verdana,Tahoma;
    text-decoration: none;
}
.propertiesboxselect
{
	font-size: 11px;
	font-family: Verdana,Tahoma;
	font-weight:normal;
}
.propertiesboxpropertytitle
{
	font-size: 11px;
	font-family: Verdana,Tahoma;
	font-weight:normal;
	background: #C4D2FB;
}
.propertiesboxinputs
{
    FONT-SIZE: 11px;
    FONT-FAMILY: Verdana,Tahoma;
	border: 0px #737373 solid;
	text-decoration: none;
}
.propertiesboxinputstable
{
	background: White;
	font-size: 11px;
	font-family: Verdana,Tahoma;
	color: Black;
}
.propertiesboxinputbutton
{
    FONT-SIZE: 11px;
    FONT-FAMILY: Verdana,Tahoma;
    BACKGROUND-COLOR: #889CD5;
    color:White;
    border-color:White;
}



TD
{
    FONT-SIZE: 10px;
    FONT-FAMILY: Verdana,Tahoma
}
A
{
    COLOR: navy
}
.linkinputs
{
    FONT-SIZE: 11px;
    FONT-FAMILY: Verdana,Tahoma;
    text-decoration: none;
    border: 1px #737373 solid;
    width: 200px
}
.returninputs
{
    FONT-SIZE: 11px;
    FONT-FAMILY: Verdana,Tahoma;
    text-decoration: none;
    border: 1px #737373 solid;
    width: 150px
}
.inputs
{
    FONT-SIZE: 12px;
    FONT-FAMILY: Verdana,Tahoma;
    text-decoration: none;
    border: 1px #737373 solid
}
.lockedinputs
{
    FONT-SIZE: 11px;
    FONT-FAMILY: Verdana,Tahoma;
    BACKGROUND-COLOR: #DBEAF5;
}
.buttons
{
    FONT-SIZE: 11px;
        FONT-FAMILY: Verdana,Tahoma;
        BACKGROUND-COLOR: #cccccc;
        color:black;
    border-color:silver;
}
.pageheader
{
    FONT-WEIGHT: bold;
    FONT-SIZE: 12px;
    FONT-FAMILY: Verdana,Tahoma
}
.properties
{
    FONT-SIZE: 11px;
    COLOR: maroon;
    FONT-FAMILY: Verdana,Tahoma
}
.list
{
    FONT-SIZE: 11px;
    FONT-FAMILY: Verdana, Tahoma
}
.propertyselected
{
    BACKGROUND-COLOR: midnightblue
}
.propertytableinputs
{
    FONT-SIZE: 11px;
    FONT-FAMILY: Verdana,Tahoma;
	border: 1 solid white;
	text-decoration: none;
}
.propertypage
{
	background-color : #93BEE2;
}
.controlbg
{
	background-color : #93BEE2;
}
.gridtableinputs
{
    FONT-SIZE: 11px;
    FONT-FAMILY: Verdana,Tahoma;
	border: 1 solid white;
}
.gridanchor
{
    FONT-SIZE: 10px;
    FONT-FAMILY: Verdana,Tahoma;
	text-decoration:none;
}
	</STYLE>
	<body marginheight="0" marginwidth="0" topmargin="0" onload="init();">
			<TABLE width="100%" bgcolor="White" cellspacing="2" cellpadding="0" ID="Table2" border="0">
				<TR>
					<TD HEIGHT="30">Build condition for selecting resources<br>
						<table border="0" ID="Table1" cellspacing="0" cellpadding="0">
							<TR>
								<TD>
									<SELECT id="Select1" name="Select1" class="propertiesboxselect" onchange="return Select1_onchange();">
										<OPTION value="(,(" selected>'('</OPTION>
										<%#resourcepropertyvalues%>
									</SELECT>
								</TD>
								<TD>
									<SELECT id="Select2" name="Select2" class="propertiesboxselect">
										<OPTION value=" = " selected>=</OPTION>
										<OPTION value=" > ">&gt;</OPTION>
										<OPTION value=" < ">&lt;</OPTION>
										<OPTION value=" >= ">&gt;=</OPTION>
										<OPTION value=" <= ">&lt;=</OPTION>
										<OPTION value=" <> ">&lt;&gt;</OPTION>
										<OPTION value=" IN ">IN</OPTION>
										<OPTION value=" Contains ">Contains</OPTION>
									</SELECT>
								</TD>
								<TD>
									<SELECT id="Select3" name="Select3" class="propertiesboxselect" language="javascript" onchange="return Select3_onclick();">
										<OPTION value="Value" selected>Value</OPTION>
										<OPTION value=""></OPTION>
									</SELECT>
								</TD>
								<TD>
									<div id="expr2">&nbsp;</div>
								</TD>
								<TD>
									<SELECT id="Select5" name="Select5" class="propertiesboxselect">
										<OPTION value="End" selected>End</OPTION>
										<OPTION value=" And ">And</OPTION>
										<OPTION value=" Or ">Or</OPTION>
										<OPTION value=") And ">')' And</OPTION>
										<OPTION value=") Or ">')' Or</OPTION>
									</SELECT>
								</TD>
								<TD valign="center" align="middle" width="200">
									<INPUT id="Button1" class="buttons" type="submit" value="Add" name="Button1" onclick="return Button1_onclick();">
									<INPUT id="undo" class="buttons" type="button" value="Undo" name="undo" language="javascript" onclick="return undo_onclick()">
								</TD>
							</TR>
						</table>
					</TD>
				</TR>
				<TR>
					<TD height="1" bgcolor="black"><IMG src="<%#VirtualDirectory%>/images/spacer.gif" height="1"></TD>
				</TR>
				<TR>
					<TD height="1" bgcolor="white"><IMG src="<%#VirtualDirectory%>/images/spacer.gif" height="1"></TD>
				</TR>
				<TR>
					<TD>
						<!--Iframe detaisl gets loaded from ResourceFilter1.htm-->
						<iframe width="100%" frameborder="no" id="expr" SRC="<%#iframeuri%>"></iframe>
					</TD>
				</TR>
				<TR>
					<TD height="1" bgcolor="black"><IMG src="<%#VirtualDirectory%>/images/spacer.gif" height="1"></TD>
				</TR>
				<TR>
					<TD height="1" bgcolor="white"><IMG src="<%#VirtualDirectory%>/images/spacer.gif" height="1"></TD>
				</TR>
				<TR>
					<TD align="right" height="30">
						<INPUT id="Button2" class="buttons" type="button" value="Clear" name="Button2" language="javascript" onclick="return Button2_onclick()">
						<INPUT id="button3" class="buttons" type="button" value="Update" name="button3" onclick="return submitform();">
						<INPUT id="button4" class="buttons" type="button" value="Close" name="button4" onclick="javascript:window.close();">
					</TD>
				</TR>
			</TABLE>
		<script language="javascript">
		var i=0;
		var oexprstr;
		var sExpression="";
		var sDispExpression="";
		var iOpenBrackets=0;

		var undoExpression;
		var undoDispExpression;
		var undoOpenBrackets;


		var valuediv = "<input id='valueinput' type='text' class='propertiesboxinput'>";

		var oexpr2;

		oexpr2 = document.getElementsByTagName("div")["expr2"];

		function changeDiv( divvar )
		{
			if( !oexpr2 )
				oexpr2 = document.getElementsByTagName("div")["expr2"];

			oexpr2.innerHTML = eval(divvar);
		}

		function Select3_onclick()
		{
			var oselect3 = document.getElementsByTagName("select")["Select3"];

			switch(oselect3.value)
			{
				case "Value": changeDiv("valuediv");
							break;
				case "Variable": changeDiv("variablediv");
								break;

				case "Content": changeDiv("contentdiv");
								break;
			}

			return false;
		}

		function init()
		{
			Select3_onclick();
			Select1_onchange();
			document.getElementsByTagName("input")["undo"].disabled=true;
			document.getElementsByTagName("input")["button3"].disabled=true; //Submit button initially disabled
			if( sExpression != "" )
				document.getElementsByTagName("input")["Button1"].disabled=true; //Disable Add button
			else
				document.getElementsByTagName("input")["Button1"].disabled=false; //Enable Add button


			if(window.opener.document.getElementsByTagName("input")["ResourcesDispExpression"] != null)
			{
				sDispExpression = 	window.opener.document.getElementsByTagName("input")["ResourcesDispExpression"].value
			}
			show_expression(sDispExpression);
		}

		function Select1_onchange()
		{
			var oselect1 = document.getElementsByTagName("select")["Select1"];
			var odiv = document.getElementsByTagName("div")["otherinputs"];
			var o = document.getElementsByTagName("*")["valueinput"];

			var values = oselect1.value.split(",");

			switch(values[1])
			{
				case "(":  document.getElementsByTagName("select")["Select2"].disabled=true;
						document.getElementsByTagName("select")["Select3"].disabled=true;
   						document.getElementsByTagName("select")["Select5"].disabled=true;
						if( o )  o.disabled=true;
 						break;
				default:   document.getElementsByTagName("select")["Select2"].disabled=false;
						document.getElementsByTagName("select")["Select3"].disabled=false;
						document.getElementsByTagName("select")["Select5"].disabled=false;
						if( o) o.disabled=false;
						break;
			}

		}


		function get_framediv()
		{
			var framedoc;

			var frameobj;

			if(navigator.userAgent.indexOf("Netscape") >0 )
			{
				document.all = document.getElementsByTagName("iframe");
				frameobj = document.all["expr"];
				framedoc = frameobj.contentDocument.getElementsByTagName("*");
				oexprstr = framedoc["exprstr"];
			}
			else
			{
				frameobj = document.frames["expr"];
				oexprstr = frameobj.document.all["exprstr"];
			}

		}

		function show_expression(expression)
		{
			if( !oexprstr )
				get_framediv();
			oexprstr.innerHTML = expression;
		}

		function set_undovalues()
		{
			undoExpression = sExpression;
			undoDispExpression = sDispExpression;
			undoOpenBrackets = iOpenBrackets;
			document.getElementsByTagName("input")["undo"].disabled=false;
		}

		function Button1_onclick()
		{
			var retval=false;

			var oselect1 = document.getElementsByTagName("select")["Select1"];
			var select1values = oselect1.value.split(",");
			var parentvalue = window.opener.document.getElementsByTagName("select")["selquery"].value

			if( select1values[1] == "(" )
			{
				set_undovalues();
				sExpression += "(";
				sDispExpression += "(";
				iOpenBrackets++;
			}
			else
			{
				var oselect2 = document.getElementsByTagName("select")["Select2"];
				var oselect3 = document.getElementsByTagName("select")["Select3"];
				var oselect5 = document.getElementsByTagName("select")["Select5"];
				//var o = document.getElementsByTagName("*")["valueinput"];
				//For IE 5.5 compatibility
				if(typeof(document.getElementsByTagName("input")["valueinput"]) != 'undefined')
					var o = document.getElementsByTagName("input")["valueinput"];
				else if(typeof(document.getElementsByTagName("select")["valueinput"]) != 'undefined')
					var o = document.getElementsByTagName("select")["valueinput"];
				else
					var o = document.getElementsByTagName("*")["valueinput"];
				var endcond=false;

				if( oselect5.value.substring(0,1) == ")" ) //Incase no open brackets pending dont allow to close the bracket
					if( iOpenBrackets <= 0 )
						return retval;
					else
						iOpenBrackets--;


				if( oselect5.value == "End" )
					endcond=true;

				set_undovalues();

				sExpression += "["; sDispExpression += "[";
				sExpression += select1values[1]; sDispExpression += select1values[0];
				sExpression += "]"; sDispExpression += "]";
				sExpression += oselect2.value; sDispExpression += oselect2.value;
				sExpression += "["; sDispExpression += "[";

				if( oselect3.value != "Value" )
				{
					if(typeof(((o.value.split(","))[1])) == 'undefined')
					{
						sExpression += ((o.value.split(","))[0]);
					}
					else
					{
						sExpression += ((o.value.split(","))[1]);
					}
					sDispExpression += ((o.value.split(","))[0]);
				}
				else
				{

				 	if(o.value.indexOf("?") >=0)
				 		sExpression += '"'+ parentvalue +'.'+ select1values[0] +'.'+ o.value+'"';
				 	else
				 		sExpression += '"'+o.value+'"';

				 	sDispExpression += '"'+o.value+'"';
				}

				sExpression += "]"; sDispExpression += "]";

				if( !endcond )
				{
					sExpression += " "+oselect5.value;
					sDispExpression += " "+oselect5.value;
				}
				else
				{
					while( iOpenBrackets > 0)
					{
						sExpression += ")"; sDispExpression += ")";
						iOpenBrackets--;
					}
					document.getElementsByTagName("input")["button3"].disabled=false; //Enable submitt button
					document.getElementsByTagName("input")["Button1"].disabled=true; //Disable Add button
				}
			}

			show_expression(sDispExpression);
			return retval;
		}

		function Button2_onclick()
		{
			sExpression="";
			sDispExpression="";
			iOpenBrackets=0;
			document.getElementsByTagName("input")["button3"].disabled=true; //Submit button initially disabled
			document.getElementsByTagName("input")["Button1"].disabled=false; //Enable Add button
			show_expression(sDispExpression);
		}

		function undo_onclick()
		{
			sExpression = undoExpression;
			sDispExpression = undoDispExpression;
			iOpenBrackets = undoOpenBrackets;
			document.getElementsByTagName("input")["undo"].disabled=true; //Disable undo button
			document.getElementsByTagName("input")["button3"].disabled=true; //Disable Submit button
			document.getElementsByTagName("input")["Button1"].disabled=false; //Enable Add button
			show_expression(sDispExpression);
		}

		function ConvertToString(  number,  width )
		{
			var str="";
			var i;

			str=number.toString();
			var l = str.length;
			for(i=0;i<(width-l);i++)
			{
				str = "0" + str;
			}
			return str.substring(0,width);
		}

		function submitform()
		{

			var submitvalue="";
			if(window.opener.document.getElementsByTagName("input")["ResourcesExpression"].value.indexOf("^") > 0 )
			{
				window.opener.document.getElementsByTagName("input")["Button1"].disabled = true;
				window.opener.document.getElementsByTagName("input")["undo"].disabled = false;

			}
			<!--Resource expression is used for building (parsing) the query -->
			<!--ResourcesDispExpression used only to list the resources names for dynamic value set for building the query -->
			window.opener.document.getElementsByTagName("input")["ResourcesExpression"].value = 'Resource.^'+ sExpression + '^'
			window.opener.document.getElementsByTagName("input")["ResourcesDispExpression"].value = sDispExpression
			window.opener.document.getElementsByTagName("*")["valueinput"].value = "1";
			window.close();
		}
		</script>
	</body>
</html>
